@extends('admin.layout.index')
@section('content')
@if (count($errors) > 0)
	<script>
		alert('{{ $errors }}');
	</script>
@endif
<div class="portlet box blue">

		<div class="portlet-title">

			<div class="caption"><i class="icon-reorder"></i>角色授权</div>

			<div class="tools">

				<a href="javascript:;" class="reload"></a>


			</div>

		</div>

		<div class="portlet-body form">


			<!-- BEGIN FORM-->

			<form action="/admin/per" class="form-horizontal" method="post">
				{{ csrf_field() }}
				<div class="control-group warning">

					<label class="control-label" for="inputWarning">角色名</label>

					<div class="controls">

						<input type="text" class="span6 m-wrap" id="username" name="name" value="{{ $role['name'] }}">

						<span class="help-inline" id='userSpan'></span>

					</div>

				</div>
				
				
				<div class="control-group warning">

					<label class="control-label">权限</label>

					<div class="controls">
						@foreach($pers as $v)
						<label class="checkbox">
						<input type="hidden" name="rid" value="{{ $role['id'] }}">
						<div class="checker"><span class='a @if(in_array($v["id"],$per)) checked @endif' ><input type="checkbox"  @if(in_array($v["id"],$per)) checked @endif name="pid[]" value="{{ $v['id'] }}" ></span></div> {{ $v['name'] }}

						</label>
						@endforeach
					</div>

					<script>
						$('.addSpan').addClass('checked')
						$('.a').click(function(){
							$(this).toggleClass('checked')
						})
					</script>
				</div>
				


				<div class="form-actions">
					<input type="submit" class="btn blue" id="submit" value="授权">
					<button type="reset" class="btn">重置</button>
				</div>
				
				

			</form>

			<!-- END FORM-->

		</div>

	</div>
@endsection